All Questions
Tagged with scalacoding-style
5 questions
26votes
6answers
7kviews
Why use Either over (checked) Exception?
Not too long ago I started using Scala instead of Java. Part of the "conversion" process between the languages for me was learning to use Eithers instead of (checked) Exceptions. I've been coding this ...
4votes
1answer
106views
Code style for parse-methods in Scala?
Say I have a class with multiple parameters: case class Foo(a: String, b: String, c: String, d: String, ... ) Now say I want to parse an instance of Foo from a Map[String, String]: // returns either ...
5votes
1answer
141views
Why would you document a return type using scaladoc?
The following is snippet of an example from page 240 of the book Programming Scala (Wampler & Payne, 2009; O'Reilly Media): /** @return Parser[Money] */ def deductItem = deductKind ~> ...
0votes
1answer
146views
Preferred Scala code style for several embedded brace sets
I was wondering the correct way to format a situation such as this, where I have a def, a foreach and an if clause all nested, requiring braces. Currently I find it hard to read, and there is no ...
10votes
2answers
9kviews
Should I use semicolons to delimit Scala statements?
I'm used to delimit statements by a semicolon from Java, so naturally I do it in Scala code too. I also feel that the code is easier to read, because it's evident where one statement ends and another ...